<template>
  <div class="container_detail coupon-edit">
    <div class="header">
      <p>福利卡管理>查看福利卡</p>
      <el-button class="link" type="primary">
        <router-link :to="{path:'couponList',query: { pageIndex: currentPage }}" style="color: #fff;">返回</router-link>
      </el-button>
    </div>
    <div class="main">
      <el-form :model="user" :rules="rules" ref="user" label-width="120px" class="">
        <div class="list">
          <div class="title">查看福利卡</div>
          <el-form-item prop="goodsName">
            <div class="item">
              <div class="item-key">卡号:</div>
              <div class="item-value">
                {{user.couponCode}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="price">
            <div class="item">
              <div class="item-key">卡密:</div>
              <div class="item-value">
                {{user.couponPsw}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="price">
            <div class="item">
              <div class="item-key">福利卡券名称:</div>
              <div class="item-value">
                {{user.couponName}}
              </div>
            </div>
          </el-form-item>
           <el-form-item prop="price">
            <div class="item">
              <div class="item-key">使用范围描述:</div>
              <div class="item-value">
                {{user.useRangeDetail}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="stockNum">
            <div class="item">
              <div class="item-key">使用范围-商品分类:</div>
              <div class="item-value">
               <span v-for="item in user.useCategoryDTO" :key="item.id">{{item.categoryName}}</span>
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">使用范围-商品品牌:</div>
              <div class="item-value">
               <span v-for="item in user.useBrandDTO" :key="item.id">{{item.brandName}}</span>
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">类型:</div>
              <div class="item-value">
               {{user.type == 'real'?'实体卡':'虚拟卡'}}
              </div>
            </div>
          </el-form-item>
         <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">余额:</div>
              <div class="item-value">
               {{user.restPrice}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">总金额:</div>
              <div class="item-value">
               {{user.price}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">有效期:</div>
              <div class="item-value">
               {{user.validTime}}
              </div>
            </div>
          </el-form-item>
          
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">激活情况 :</div>
              <div class="item-value">
               {{user.status == 'y'?'已激活':'失效'}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">充值情况 :</div>
              <div class="item-value">
               {{user.isRecharge == 'y'?'已充值':'待充值'}}
              </div>
            </div>
          </el-form-item>
           <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">充值手机号:</div>
              <div class="item-value">
               {{user.mobile}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">消费记录:</div>
              <div class="item-value">
               <div v-for="(item,index) in user.payOrderDTOS" :key="index">
                 {{item.gmtCreated}}  <span style="margin:0 10px;">{{item.goodsName}}</span>     ¥{{item.totalPrice}}
               </div>
               
              </div>
            </div>
          </el-form-item>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
let CONSTANT = require("../../constant/constant.js");
let common = require("../../common.js");
let countryArr = require("../../../static/city.json");
export default {
  data() {
    return {
      id: "",
      info: "",
      // 返回 导航页码
      currentPage: 1,
      user: {},
     typeArr:[
        {
            name:'实体商品',
            value:'real'
        },
         {
            name:'自营电子券',
            value:'virtual'
        },
        {
            name:'第三方电子券',
            value:'third'
        }
      ],
      brandArr:[],
      sortArr:[],
      provinceArr :[],
      cityArr:[],
      rules:{}
    };
  },
  mounted() {
    this.provinceArr = countryArr.provinces.province,
    this.id = this.$router.currentRoute.query.id;
    this.currentPage = this.$router.currentRoute.query.pageIndex
      ? this.$router.currentRoute.query.pageIndex
      : 1;
    this.getDetail();
  },
  methods: {
    returnName(val){
        let str;
        this.typeArr.map(item=>{
            if(item.value == val){
                str = item.name
            }
        })
        return str
    },
    getDetail() {
      let url = CONSTANT.URL.LIST.findEsCouponById;
      let data = { id: this.id }
      common.requestAjax(url, JSON.stringify(data), null, res => {
        this.user = res.data.bussData;
      });
    }
  }
};
</script>
<style lang="scss">
.coupon-edit {
  .el-form-item {
    margin: 0px;
    
  }

  .item-value {
    .el-input {
      width: 50%;
    }
    .el-select {
      width: 50%;
      .el-input {
        width: 100%;
      }
    }
  }
  .el-form-item__content {
    margin: 0px !important;
  }
}
</style>

